package cwb1;

import java.util.Date;
import java.util.HashMap;
import java.util.Map;

/**
 * This class represents a sleep activity.
 * 
 * @author Aurora
 *
 */
public class Sleep extends Activity
{
	// A personal rate for the clear mind feeling after the sleep activity.
    private long wakeUpRate;
    
    /**
     * This method makes a sleep (activity) object.
     * 
     * @param startDate The start date of the sleep activity.
     * @param userId The userId of the user who has done the sleep activity.
     */
    public Sleep(Date startDate, String userId)
    {
        super(startDate, userId, ActivityFactory.SLEEP);
        wakeUpRate = 0;
    }
    
    /**
     * Creates a Sleep activity using the values of the Map to set the fields. Be warned, the values are not checked.
     * 
     * @param properties The Map containing the keys: for creating an activity, "wakeUpRate" with long.
     */
    public Sleep(Map<String, Object> properties) {
    	super(properties);
    	setActivityType(ActivityFactory.SLEEP);
    	wakeUpRate = (Long) properties.get("wakeUpRate");
    }
    
    /**
     * This method returns the properties (personal rates) of the sleep activity.
     * 
     * return HashMap with the properties (personal rates) as content and the name of the properties as corresponding key.
     */
    public HashMap<String,Object> getProperties() {
    	HashMap<String, Object> properties = super.getProperties();
    	properties.put("wakeUpRate", wakeUpRate);
    	
    	return properties;
    }
    
    /**
     * This method returns the wake up rate of the sleep activity.
     * 
     * @return The wake up rate of the sleep activity.
     */
    public long getWakeUpRate()
    {
        return wakeUpRate;
    }
    
    /**
     * This method changes the wake up rate of the sleep activity to the given value.
     * 
     * @param value The new value for the wake up rate of the sleep activity.
     */
    public void setWakeUpRate(long value)
    {
        wakeUpRate = value;
    }
    
   
}
